﻿using System.Collections.Generic;

namespace RouteMaster
{
    public class RealWorld : iWorld
    {
        public readonly Dictionary<int, BusStop> _theStopsById = new Dictionary<int, BusStop>();
        public readonly AllRoutes _all = new AllRoutes();

        public BusRoute TryGetRoute(int id, string sz, string vehicleType)
        {
            BusRoute busRoute;

            if (!_all._routes.TryGetValue(id, out busRoute))
            {
                busRoute = new BusRoute(id, sz, vehicleType, this);
                _all.Add(busRoute);
            }
            return busRoute;
        }

        public BusRoute GetRoute(int id)
        {
            return _all._routes[id];
        }

        public void AddBusStop(int index, string name)
        {
            _theStopsById.Add(index, new BusStop(index, name));
        }

        public BusStop GetById(int id)
        {
            return _theStopsById[id];
        }
    }
}
